package org.example.springaitest.config;

import org.example.springaitest.retriever.Neo4jVectorDocumentRetriever;
import org.neo4j.driver.Driver;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.rag.advisor.RetrievalAugmentationAdvisor;
import org.springframework.ai.rag.retrieval.search.DocumentRetriever;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RagConfig {

    @Bean
    public DocumentRetriever neo4jRetriever(
            @Qualifier("neo4jVectorStore") VectorStore vectorStore,
            Driver driver) {
        return new Neo4jVectorDocumentRetriever(vectorStore, driver, 3);
    }
    @Bean
    public Advisor neo4jRagAdvisor(DocumentRetriever neo4jRetriever) {
        return RetrievalAugmentationAdvisor.builder()
                .documentRetriever(neo4jRetriever)
                .build();
    }
}
